/*
 * VirtualHardwareController.hpp
 *
 *  Created on: 13 dec. 2012
 *      Author: Admin
 */

#ifndef VIRTUALHARDWARECONTROLLER_HPP_
#define VIRTUALHARDWARECONTROLLER_HPP_

#include "HardwareController.hpp"
#include "Protocol.hpp"

class VirtualHardwareController: public HardwareController
{
public:

	static VirtualHardwareController& getHardwareController();

	virtual ~VirtualHardwareController();

	/**
	 * Polls the light sensor on the left side of the robot
	 */
	virtual bool pollColorlaneLeft();

	/**
	 * Polls the light sensor on the right side of the robot
	 */
	virtual bool pollColorlaneRight();

	/**
	 * Polls the side exit sensor on the left side of the robot
	 */
	virtual bool pollSideExitLeft();

	/**
	 * Polls the side exit sensor on the right side of the robot
	 */
	virtual bool pollSideExitRight();

	/**
	 * Polls the cross roads sensor
	 */
	virtual bool pollCrossRoadsSensor();

	/**
	 * Polls the CollisionSensor mounted on the backside of the robot
	 */
	virtual bool pollCollisionSensorBack();

	/**
	 * Polls the CollisionSensor mounted on the frontside of the robot
	 */
	virtual bool pollCollisionSensorFront();

	/**
	 * Polls the DistanceSensor
	 */
	virtual bool pollDistanceSensor();

	/**
	 * Polls the EmergencyStop
	 */
	virtual bool pollEmergencyStop();

	/**
	 * Activates the wheels (enables the brick control actuator)
	 */
	virtual void activateWheels();

	/**
	 * Disables the wheels (disables the brick control actuator)
	 */
	virtual void disableWheels();

	/**
	 * Activates the LED
	 */
	virtual void activateLED();

	/**
	 * Disables the LED
	 */
	virtual void disableLED();

	/**
	 * Makes the left wheel turn forward
	 */
	virtual void leftWheelForward();

	/**
	 * Makes the left wheel turn backward
	 */
	virtual void leftWheelBackward();

	/**
	 * Makes the right wheel turn forward
	 */
	virtual void rightWheelForward();

	/**
	 * Makes the right wheel turn backward
	 */
	virtual void rightWheelBackward();

	/**
	 * Wait a certain amount of ms
	 * @param ms amount of milliseconds the robot should wait
	 */
	virtual void wait(unsigned int ms);

	/**
	 * Wait a certain amount of ms and decrements the given paramater
	 * @param ms amount of milliseconds the robot should wait, this value will be decremented by 1 for every ms that has passed
	 */
	virtual void wait(unsigned int* ms);

	/**
	 * Processes a trigger
	 */
	void processTrigger(Protocol::Trigger trigger);

	/**
	 * Send all possible updates to this client
	 */
	void updateClient(unsigned int clientID);

	/**
	 * Sends all possible updates to all clients
	 */
	void updateClients();

	/**
	 * Resets the virtual hardware controller
	 */
	void resetHardwareController();
private:
	VirtualHardwareController();

	bool
	//Signals
	colorlaneLeftSignal, colorlaneRightSignal, crossroadsSignal, collisionBackSignal, collisionFrontSignal,
	distanceSignal, emergencySignal, sideExitLeftSignal, sideExitRightSignal,
	//Toggles
	colorlaneLeftToggle, colorlaneRightToggle, crossroadsToggle, collisionBackToggle, collisionFrontToggle,
	distanceToggle, emergencyToggle, sideExitLeftToggle, sideExitRightToggle,
	//Status
	buzzer, led1, led2, wheelControl, /*leftWheel, rightWheel,*/ sleep;
	Protocol::WheelStatus leftWheel, rightWheel;
};

#endif /* VIRTUALHARDWARECONTROLLER_HPP_ */
